﻿@using System.Text.RegularExpressions
@using Easy.Web.CMS
@using Easy.Web.CMS.Layout
@model LayoutEntity
@{
    if (Model == null)
    {
        return;
    }
}
@for (int i = 0; i < Model.Html.Count; i++)
{
    var item = Model.Html[i];
    if (item.Html == Easy.Web.CMS.Zone.ZoneEntity.ZoneTag)
    {
        i++;
        var zoneId = Model.Html[i].Html;
        if (Model.ZoneWidgets.ContainsKey(zoneId))
        {
            foreach (var widgetPart in Model.ZoneWidgets[zoneId].OrderBy(m => m.Widget.Position).ThenBy(m => m.Widget.WidgetName))
            {
                <div @widgetPart.Widget.StyleClassResult()>
                    @Html.DisPlayWidget(widgetPart)                    
                </div>
            }
        }
        i++;
    }
    else
    {
        @Html.Raw(item.Html)
    }
}

